Skip to contentSkip to conversation

Change in openvpn[master]: Use a more robust way to get dco-win version

Openvpn-devel In review stipa (Code Review) 2 participants 6 messages Aug 9, 2024 – Aug 13, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1723205005000.Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/723?usp=email

to review the following change.

Change subject: Use a more robust way to get dco-win version
......................................................................

Use a more robust way to get dco-win version

The current way doesn't work if the device is already in use.

Starting from 1.3.0, dco-win creates a non-exclusive control device \\.\ovpn-dco-ver which can be opened by multiple apps and supports a single IOCTL to get a version number.

https://github.com/OpenVPN/ovpn-dco-win/pull/76

This will be expecially handy later when checking which features driver supports.

Change-Id Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf

---
M src/openvpn/dco_win.c

1 file changed, 10 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/723/1

src/openvpn/dco_win.c +10 -3
index e3ada76..3ec946f 100644
@@ -389,9 +389,16 @@
     OVPN_VERSION version;
     ZeroMemory(&version, sizeof(OVPN_VERSION));
 
-    /* try to open device by symbolic name */
-    HANDLE h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRITE,
-                          0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, NULL);
+    /* first, try a non-exclusive control device, available from 1.3.0 */
+    HANDLE h = CreateFile("\\\\.\\ovpn-dco-ver", GENERIC_READ,
+                          0, NULL, OPEN_EXISTING, 0, NULL);
+
+    if (h == INVALID_HANDLE_VALUE)
+    {
+        /* fallback to a "normal" device, this will fail if device is already in use */
+        h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ,
+                       0, NULL, OPEN_EXISTING, 0, NULL);
+    }
 
     if (h == INVALID_HANDLE_VALUE)
     {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/723?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf
Gerrit-Change-Number: 723
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/723?usp=email )

Change subject: Use a more robust way to get dco-win version
......................................................................

Patch Set 1: Code-Review+2

(1 comment)

Patchset:

PS1:
Looks good. Helps reduce friction (= avoid misleading error messages in log) when multiple programs are active, and possibly multiple DCO interfaces. Matches driver code change.

Build errors are due to socks proxy not running, independent of the change here.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/723?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf
Gerrit-Change-Number: 723
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 09 Aug 2024 19:21:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Use a more robust way to get dco-win version

In reply to a message not in the archive

From: Lev Stipakov <[email protected]...>

The current way doesn't work if the device is already in use.

Starting from 1.3.0, dco-win creates a non-exclusive control device \\.\ovpn-dco-ver which can be opened by multiple apps and supports a single IOCTL to get a version number.

https://github.com/OpenVPN/ovpn-dco-win/pull/76

This will be expecially handy later when checking which features driver supports.

Change-Id Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/723
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/dco_win.c +10 -3
index e3ada76..3ec946f 100644
@@ -389,9 +389,16 @@
     OVPN_VERSION version;
     ZeroMemory(&version, sizeof(OVPN_VERSION));
 
-    /* try to open device by symbolic name */
-    HANDLE h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRITE,
-                          0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, NULL);
+    /* first, try a non-exclusive control device, available from 1.3.0 */
+    HANDLE h = CreateFile("\\\\.\\ovpn-dco-ver", GENERIC_READ,
+                          0, NULL, OPEN_EXISTING, 0, NULL);
+
+    if (h == INVALID_HANDLE_VALUE)
+    {
+        /* fallback to a "normal" device, this will fail if device is already in use */
+        h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ,
+                       0, NULL, OPEN_EXISTING, 0, NULL);
+    }
 
     if (h == INVALID_HANDLE_VALUE)
     {
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Use a more robust way to get dco-win version

Stared at code here and on the driver side, looks very reasonable and also backward-compatible in both directions.

Not actually tested, just test compiled via GHA.

Your patch has been applied to the master and release/2.6 branch (long-term compat).

commit e5a8ea36a0228c30cdbee8791d44a1f0fbaffa9f (master) commit 41fe48585ebd005e65d191452c2860ab9c089c55 (release/2.6)

Author: Lev Stipakov
Date:   Fri Aug 9 21:22:56 2024 +0200
     Use a more robust way to get dco-win version

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg29009.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/723?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Use a more robust way to get dco-win version
......................................................................

Use a more robust way to get dco-win version

The current way doesn't work if the device is already in use.

Starting from 1.3.0, dco-win creates a non-exclusive control device \\.\ovpn-dco-ver which can be opened by multiple apps and supports a single IOCTL to get a version number.

https://github.com/OpenVPN/ovpn-dco-win/pull/76

This will be expecially handy later when checking which features driver supports.

Change-Id Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29009.html

---
M src/openvpn/dco_win.c

1 file changed, 10 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/723/2

src/openvpn/dco_win.c +10 -3
index e3ada76..3ec946f 100644
@@ -389,9 +389,16 @@
     OVPN_VERSION version;
     ZeroMemory(&version, sizeof(OVPN_VERSION));
 
-    /* try to open device by symbolic name */
-    HANDLE h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRITE,
-                          0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, NULL);
+    /* first, try a non-exclusive control device, available from 1.3.0 */
+    HANDLE h = CreateFile("\\\\.\\ovpn-dco-ver", GENERIC_READ,
+                          0, NULL, OPEN_EXISTING, 0, NULL);
+
+    if (h == INVALID_HANDLE_VALUE)
+    {
+        /* fallback to a "normal" device, this will fail if device is already in use */
+        h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ,
+                       0, NULL, OPEN_EXISTING, 0, NULL);
+    }
 
     if (h == INVALID_HANDLE_VALUE)
     {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/723?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf
Gerrit-Change-Number: 723
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/723?usp=email )

Change subject: Use a more robust way to get dco-win version
......................................................................

Use a more robust way to get dco-win version

The current way doesn't work if the device is already in use.

Starting from 1.3.0, dco-win creates a non-exclusive control device \\.\ovpn-dco-ver which can be opened by multiple apps and supports a single IOCTL to get a version number.

https://github.com/OpenVPN/ovpn-dco-win/pull/76

This will be expecially handy later when checking which features driver supports.

Change-Id Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29009.html

---
M src/openvpn/dco_win.c

1 file changed, 10 insertions(+), 3 deletions(-)
src/openvpn/dco_win.c +10 -3
index e3ada76..3ec946f 100644
@@ -389,9 +389,16 @@
     OVPN_VERSION version;
     ZeroMemory(&version, sizeof(OVPN_VERSION));
 
-    /* try to open device by symbolic name */
-    HANDLE h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRITE,
-                          0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, NULL);
+    /* first, try a non-exclusive control device, available from 1.3.0 */
+    HANDLE h = CreateFile("\\\\.\\ovpn-dco-ver", GENERIC_READ,
+                          0, NULL, OPEN_EXISTING, 0, NULL);
+
+    if (h == INVALID_HANDLE_VALUE)
+    {
+        /* fallback to a "normal" device, this will fail if device is already in use */
+        h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ,
+                       0, NULL, OPEN_EXISTING, 0, NULL);
+    }
 
     if (h == INVALID_HANDLE_VALUE)
     {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/723?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf
Gerrit-Change-Number: 723
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged